# coding:utf-8
class MessageWarnning < ActiveRecord::Base
	MSG_INFO = MobileMsg::ERROR_CODE.merge(0 => "连接短信服务器失败",1 => "正常")

  scope :by_warnning_code, lambda { |warnning_code| 
    if warnning_code == 'error'
      where("message_warnnings.warnning_code <= 0")
    else
      where(["message_warnnings.warnning_code = ?", warnning_code])
    end
  }
  scope :before_date, lambda {|date| where(["message_warnnings.created_at < ?", 1.days.since(Time.zone.parse(date)).strftime("%Y-%m-%d")])}
  scope :after_date, lambda {|date| where(["message_warnnings.created_at >= ?", date])}

	def display_name
		MSG_INFO[self.warnning_code]
	end

end
